<div class="container">
<?php
if (empty($datalist)) {
	echo "<h3>Data masih kosong!</h3>";
}
else {
?>
			<table id="my_data_list" class="table table-striped table-bordered" cellspacing="0" width="100%">
				<thead>
					<tr>
						<th>NIK</th>
						<th>Nama</th>
						<th>Departemen</th>
						<th>Tanggal</th>
						<th>Checklist Safety Patrol</th>
						<th>Laporan Hasil Pemeriksaan Bulanan</th>
						<th>Laporan Fasilitas K3</th>
						<th>Kartu Stop</th>
					</tr>
				</thead>
				<tbody>
				<?php
				
				$no = 1;
				//print_r($datalist);
				//echo $datalist[0]['anggota'];
				
				foreach ($datalist as $key => $value) {
					$return[$value['anggota']][] = $value['departemen'];
					
					if(empty($value['data1']))
					{
					$return[$value['anggota']][] = "";
					}
					else
					{
					$return[$value['anggota']][] = $value['data1'];
					}
					
					if(empty($value['data2']))
					{
					$return[$value['anggota']][] = "";
					}
					else
					{
					$return[$value['anggota']][] = $value['data2'];
					}
					
					if(empty($value['data3']))
					{
					$return[$value['anggota']][] = "";
					}
					else
					{
					$return[$value['anggota']][] = $value['data3'];
					}
					
					if(empty($value['data4']))
					{
					$return[$value['anggota']][] = "";
					}
					else
					{
					$return[$value['anggota']][] = $value['data4'];
					}
					
					$return[$value['anggota']][] = $value['tanggal'];
				}

				foreach ($return as $key => $value) {
				$data_user=$this->db->get_where('user',array('NIK'=>$key))->row();
				if(empty($data_user->NAMA)) { $nama_user=""; } else { $nama_user=$data_user->NAMA; }
				if(empty($data_user->Departemen)) { $nama_dept=""; } else { $nama_dept=$data_user->Departemen; }
				if(empty($data_user->ROLE)) {}
				else
				{
					if($data_user->ROLE==1)
					{
				?>
					<tr>
						<td><?php echo $key; ?></td>
						<td><?php echo $nama_user; ?></td>
						<td><?php echo $nama_dept; ?></td>
						<td><?php echo date("M Y", strtotime($value[5])); ?></td>
						<?php
						if($value[1])
						{
						?>
						<td><input name="status" type="checkbox" checked disabled /></td>
						<?php
						}
						else
						{
						?>
						<td><input name="status" type="checkbox" disabled /></td>
						<?php
						}
						?>
						<?php
						if($value[2])
						{
						?>
						<td><input name="status" type="checkbox" checked disabled /></td>
						<?php
						}
						else
						{
						?>
						<td><input name="status" type="checkbox" disabled /></td>
						<?php
						}
						?>
						<?php
						if($value[3])
						{
						?>
						<td><input name="status" type="checkbox" checked disabled /></td>
						<?php
						}
						else
						{
						?>
						<td><input name="status" type="checkbox" disabled /></td>
						<?php
						}
						?>
						<?php
						if($value[4])
						{
						?>
						<td><input name="status" type="checkbox" checked disabled /></td>
						<?php
						}
						else
						{
						?>
						<td><input name="status" type="checkbox" disabled /></td>
						<?php
						}
						?>
					</tr>
				<?php
					}
				}
				}
				?>
				<?php
				/*$no = 1;
				//print_r($datalist);
				//echo $datalist[0]['anggota'];
				
				foreach ($datalist as $key => $value) {
					$return[$value['anggota']][] = $value['departemen'];
				}

				foreach ($return as $key => $value) {
				?>
					<tr>
						<td><?php echo $key; ?></td>
						<td><?php echo $value[0]; ?></td>
						<td><?php echo count($value); ?></td>
					</tr>
				<?php
				}
				*/
				/*foreach ($datalist as $data):
				?>
					<tr>
						<td><?php echo $data['anggota']; ?></td>
						<td><?php echo $data['departemen']; ?></td>
						<td><?php echo ""; ?></td>
					</tr>
				<?php
				$no++;
				endforeach;*/
				?>
				</tbody>
			</table><?php } ?>
		</div></body></html>